unit FormPesquisarSubAreaParametroUnit;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Vcl.Grids, Vcl.DBGrids,
  JvExDBGrids, JvDBGrid, System.Actions, Vcl.ActnList;

type
  TFormPesquisarSubAreaParametro = class(TForm)
    EditPesquisar: TEdit;
    JvDBGrid1: TJvDBGrid;
    Label1: TLabel;
    ActionList1: TActionList;
    Actionesc: TAction;
    procedure FormCreate(Sender: TObject);
    procedure JvDBGrid1KeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    procedure JvDBGrid1DblClick(Sender: TObject);
    procedure EditPesquisarKeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    procedure ActionescExecute(Sender: TObject);
    procedure EditPesquisarChange(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
  private
    { Private declarations }
  public
    { Public declarations }
    idsubarea : integer;
    nomesubarea : string;
  end;

var
  FormPesquisarSubAreaParametro: TFormPesquisarSubAreaParametro;

implementation

{$R *.dfm}

uses DMDadosUnt;

procedure TFormPesquisarSubAreaParametro.ActionescExecute(Sender: TObject);
begin
  idsubarea := 0;
  nomesubarea := '';
  Close;
end;

procedure TFormPesquisarSubAreaParametro.EditPesquisarChange(Sender: TObject);
begin
  DMDados.dsCadastroArea.DataSet.Filtered := false;

  DMDados.dsCadastroArea.DataSet.Filter := 'NOME LIKE '+QuotedStr('%'+EditPesquisar.Text+'%');


  DMDados.dsCadastroArea.DataSet.Filtered := true;
end;

procedure TFormPesquisarSubAreaParametro.EditPesquisarKeyDown(Sender: TObject;
  var Key: Word; Shift: TShiftState);
begin
if key = VK_RETURN then
begin
  JvDBGrid1.SetFocus;
end;
end;

procedure TFormPesquisarSubAreaParametro.FormClose(Sender: TObject;
  var Action: TCloseAction);
begin
  DMDados.dsCadastroArea.DataSet.Filtered := false;
end;

procedure TFormPesquisarSubAreaParametro.FormCreate(Sender: TObject);
begin
  idsubarea := 0;
  nomesubarea := '';

end;

procedure TFormPesquisarSubAreaParametro.JvDBGrid1DblClick(Sender: TObject);
begin
    idsubarea   := DMDados.cdsBuscaSubAreaPID_SUBAREA.AsInteger;
    nomesubarea := DMDados.cdsBuscaSubAreaPNOME.AsString;
    close;
end;

procedure TFormPesquisarSubAreaParametro.JvDBGrid1KeyDown(Sender: TObject;
  var Key: Word; Shift: TShiftState);
begin
  if key = VK_RETURN then
  begin
    idsubarea   := DMDados.cdsBuscaSubAreaPID_SUBAREA.AsInteger;
    nomesubarea := DMDados.cdsBuscaSubAreaPNOME.AsString;
    close;
  end;
end;

end.
